/*
 * Author: Rico
 *
*/

#ifndef SGLLKDLISTBSCOPS_H__
#define SGLLKDLISTBSCOPS_H__

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

// 去掉输入缓冲区中多余的字符包括换行等
#define eatline ({while(getchar()!='\n'){continue;}})

typedef int DataType;

typedef struct Node {
    DataType data;
    struct Node *link;
} Node, *NodePointer;

typedef struct List {
    NodePointer first;
    NodePointer last;
    short lenth;
} LinkedList;

Node* _creatNode(DataType nodeData);

void initList(LinkedList *list);
short isEmpty(LinkedList *list);
void displayList(LinkedList *list);
short insertAtTheEnd(LinkedList *list, DataType insertData);
short insertAtTheBeginning(LinkedList *list, DataType insertData);
short insertToOrderedList(LinkedList *list, DataType insertData);
short getLenth(LinkedList list);
Node* findInList(LinkedList *list, DataType findData);
short deleteLastData(LinkedList *list);
short deleteFirstData(LinkedList *list);
short deleteByData(LinkedList *list, DataType deleteData);
short sortList(LinkedList *list);
short reverseList(LinkedList *list);
short clearList(LinkedList *list);
void destroyList(LinkedList *list);

#endif